package com.example.demo01.Socket.Client;

import com.example.demo01.Socket.Codec.encode.MyMessageEncoder1;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;

public class ClientHandlerInitilizer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel ch) throws Exception {

        ch.pipeline().addLast(new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE, 0, 2));
        //先解码再加码
        ch.pipeline().addLast(new MyMessageEncoder1());
        ch.pipeline().addLast(new ConnectChannelInboundHandler());
        ch.pipeline().addLast(new HeartbeatHandler());

//        ch.pipeline().addLast("frameDecoder",
//                new LengthFieldBasedFrameDecoder(65535,
//                        0,2,0,
//                        2));
    }
}
